package com.seekting.mynews.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPref {

    private static SharedPreferences sharedPreferences;

    public static final String SP_KEY_BITMAP_RATIO = "sp_key_bitmap_ratio";

    public static void setString(Context context, String key, String value) {

        getSharedPref(context);
        Editor e = sharedPreferences.edit();
        e.putString(key, value);
        e.apply();
    }

    public static String getString(Context context, String key, String value) {
        getSharedPref(context);
        return sharedPreferences.getString(key, value);
    }

    private static void getSharedPref(Context context) {
        if (sharedPreferences == null) {
            Context c = context.getApplicationContext();
            sharedPreferences = c.getSharedPreferences(c.getPackageName(), Context.MODE_PRIVATE);
        }
    }

}
